//编写程序实现找出数组中的最大值和最小值然后返回
#include <stdio.h>

//int max,min;使用全局变量带出去

//自定义函数
void maxAndMin(int arr[],int len,int* pMax,int* pMin)
{
	//1.找出最大值和最小值
	//2.带出去
	// *pMax = max *pMin = min
	//pMax = pMin = &arr[0];
	*pMax = *pMin = arr[0];
	int i = 0;
	for(i = 1; i < len; i++)
	{
		if(*pMax < arr[i])
		{
			*pMax = arr[i];
		}
		if(*pMin > arr[i])
		{
			*pMin = arr[i];
		}
	}
}

int main(void)
{
	int arr[10] = {50,11,20,8,32,66,45,16,21,88};
	int max = 0,min = 0;
	maxAndMin(arr,10,&max,&min);
	printf("最大值是:%d,最小值是：%d\n",max,min);
	return 0;
}
